﻿using System;
using AudioStudio;
using AudioStudio.Components;
using UnityEngine;
using UnityEngine.Serialization;

namespace Yoozoo.Gameplay.Liberty.Media
{
    public class VehicleAudioComponent : MonoBehaviour
    {
        public AudioEmitter3D audioEmitter3D;
        
        public LoopAdjustToneSound loopAdjustToneSound;

        public VehicleCollisionSound vehicleColSound;
        
        // Sound
        public string engineSound = "SaloonCar_start_0_1001";
        
        public string brakeStartSound = "Car_brake_0_1001_Start"; 
        
        // Voice
        public string brakeEndSound = "Car_brake_0_1001_End"; 
        public string impactSound = "Car_impact_0_1001"; 
        public string openDoorSound = "Car_door_0_1001_Open"; 
        public string closeDoorSound = "Car_door_0_1001_Close"; 

        public float impactIntervalTime = 0.5f;
        public float impactMinImpulse = 10f;

        private void OnEnable()
        {
            
        }

        private void Awake()
        {
            loopAdjustToneSound.enabled = false;
            vehicleColSound.audioComponent = this;
            vehicleColSound.minInterval = impactIntervalTime;
            vehicleColSound.minImpulse = impactMinImpulse;
        }

        public void PlaySound(string sName)
        {
            AudioManager.PlaySound(sName,audioEmitter3D.gameObject);
        }

        public void StopSound(string sName)
        {
            AudioManager.StopSound(sName,audioEmitter3D.gameObject);
        }

        public void PlayVoice(string vName)
        {
            AudioManager.PlayVoice(vName,audioEmitter3D.gameObject);
        }
    }
}